import { ChangeDetectorRef, Component, OnInit } from '@angular/core';

import { OrganizationInfo } from '@app/core/domain/dashboard';
import { DashboardService } from '@app/core/services/http/dashboard/dashboard.service';
import { SharedModule } from '@app/shared/shared.module';

@Component({
  selector: 'app-organization-info',
  standalone: true,
  imports: [SharedModule],
  templateUrl: './organization-info.component.html',
  styleUrl: '../dashboard.component.less'
})
export class OrganizationInfoComponent implements OnInit {
  organizationInfoList: OrganizationInfo[] = [];

  constructor(
    private readonly dashboardService: DashboardService,
    private readonly cdr: ChangeDetectorRef
  ) {}

  loadOrganizationsData(): void {
    this.dashboardService.getOrganizationList({ '@relationships': 'all', '@filter': 'noteq(OrganizeName,息烽县人民医院)' }).subscribe(result => {
      this.organizationInfoList = result.filter(r => r.organizename !== '息烽县人民医院');
      this.cdr.markForCheck();
    });
  }

  ngOnInit(): void {
    this.loadOrganizationsData();
  }
}
